package com.example.fechat.room.user

import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.Index
import androidx.room.PrimaryKey

@Entity(tableName = "user_info", indices = [Index("userId")])
class UserEntity {
    @JvmField
    @PrimaryKey(autoGenerate = true)
    var _id = 0L

    @JvmField
    @ColumnInfo(name = "userId")
    var userId = ""

    @ColumnInfo(name = "userHead")
    var userHead = ""

    @ColumnInfo(name = "duration")
    var duration = 0L

    @ColumnInfo(name = "userName")
    var userName = ""

    @ColumnInfo(name = "last_message")
    var last_message = ""

    override fun toString(): String {
        return if (last_message.isEmpty()) {
            "{_id:$_id,userId:\"$userId\",userHead:\"$userHead\",duration:\"$duration\",userName:\"$userName\"}"
        } else {
            "{_id:$_id,userId:\"$userId\",userHead:\"$userHead\",duration:\"$duration\",userName:\"$userName\",last_message:\"$last_message\"}"
        }
    }
}